<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<c:set value="${pageContext.request.contextPath}" scope="page" var="ctx"></c:set>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	String currRequestURL="";

	try{
		currRequestURL = request.getRequestURL().toString();
	}catch(Exception e){
	}
	System.out.println("currRequestURL:"+currRequestURL);
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>扬尘设备提交基本设备信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">


        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>上传扬尘设备基本信息到工务署</legend>
        </fieldset>

        <form class="layui-form" action="">
            
              <div class="layui-form-item">
                <label class="layui-form-label">设备编号</label>
                <div class="layui-input-inline">
                    <input type="text" name="device_no" lay-verify="device_code" placeholder="(必填)，请输入设备号" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">请填写24位设备号</div>
            </div>
            
            
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">设备安装日期</label>
                    <div class="layui-input-inline">
                        <input type="text" name="device_installation_date" id="date" lay-verify="date" placeholder="年-月-日" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">请填写设备安装日期(必选)</div>
                </div>
            </div>

            
            <div class="layui-form-item">
                <label class="layui-form-label">设备名称</label>
                <div class="layui-input-block">
                    <input type="text" name="name" lay-verify="name" autocomplete="off" placeholder="(必填)，请完善信息。请输入：整数#监测点 例如：13#监测点" class="layui-input">
                </div>
            </div>
            
            
            <div class="layui-form-item">
                <label class="layui-form-label">设备类型(1&0环境)(必填)</label>
                <div class="layui-input-block">
                    <input type="radio" name="type" value="1" title="设备类型(1.环境监测)" checked="">
                </div>
            </div>
            
            
             <div class="layui-form-item">
                <label class="layui-form-label">安装位置</label>
                <div class="layui-input-inline">
                    <input type="text" name="install_address" lay-verify="install_address" placeholder="(必填)，请输入安装位置" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">请填写安装位置</div>
            </div>
            
            
             <div class="layui-form-item">
                <label class="layui-form-label">设备安装公司或单位</label>
                <div class="layui-input-inline">
                    <input type="text" name="install_company" lay-verify="install_company" placeholder="(必填)，请输入设备安装公司或单位" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">请填写安装位置</div>
            </div>
            
            
              <div class="layui-form-item">
                <label class="layui-form-label">枪机类型地址编码，没有可不填</label>
                <div class="layui-input-block">
                    <input type="text" name="device_type_qiangji" autocomplete="off" placeholder="(非必填)" class="layui-input">
                </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">球机类型地址编码，没有可不填</label>
                <div class="layui-input-block">
                    <input type="text" name="device_type_qiuji" autocomplete="off" placeholder="(非必填)" class="layui-input">
                </div>
            </div>
            
            
              <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交至DAO后台</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>

        <!-- 示例-970 -->
        <ins class="adsbygoogle" style="display:inline-block;width:970px;height:90px" data-ad-client="ca-pub-6111334333458862" data-ad-slot="3820120620"></ins>


    </div>
</div>

<script src="../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="../../../js/jquery-3.2.1.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;

        //日期
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#date1'
        });

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        form.verify({
	
        	name: [
        		 /^([\d\d])+#[\u4e00-\u9fa5]+$/
                , '请以数字开头 # 中文结尾，例如13#监测点'
            ]
            , content: function (value) {
                layedit.sync(editIndex);
            }
        	,
        	
        	device_code: [
                /^[\S]{24,24}$/
                , '设备号目前要求是必须24位'
            ]
            , content: function (value) {
                layedit.sync(editIndex);
            }
        	,
            install_address: function (value) {
                if (value.length < 1) {
                    return '安装地址至少写一个字吧。';
                }
            },
            install_company: function (value) {
                if (value.length < 1) {
                    return '安装公司至少写一个字吧。';
                }
            }
           
        });

var fromdata1;
        //监听提交
        form.on('submit(demo1)', function (data) {
  	fromdata1 = JSON.stringify(data.field);
  	layer.confirm(JSON.stringify(data.field), {icon: 3, title:'最終提交的信息如下，确定提交吗？'}, function(index){
        //do something
               $.ajax({
     type: "POST",
     url: "../../page/SubmitTspBaseInfoToGWF",
     dataType:"json",
     contentType : "application/json;charset=UTF-8",
     data: fromdata1,
     success: function (res) {
         if (res.body) {
         	 console.log(res);
         	layer.alert(res.body);
         } else {
             layer.alert("no body");
         }
     }
 });
        layer.close(index);
      });
  	
//     layer.alert(JSON.stringify(data.field), {
//         title: '最终的提交信息'
//           })

//          $.ajax({
//      type: "POST",
//      url: "../../page/SubmitTspBaseInfoToGWF",
//      dataType:"json",
//      contentType : "application/json;charset=UTF-8",
//      data: fromdata1,
//      success: function (res) {
//          if (res.body) {
//          	 console.log(res);
//          	layer.alert(res.body);
//          } else {
//              layer.alert("no body");
//          }
//      }
//  });
            
            return false;
        });



    });
</script>

</body>
</html>